<?php
namespace Home\Controller;

use Think\Controller;

class SettingController extends CommonController
{
    /**
     * 构建函数
     */
    public function __construct()
    {
        parent::__construct();
    }

    public function wxJsSDK()
    {
        Vendor('Wechat/Wechat');
        $url = I('post.url', '');

        if (!is_url($url)) {
            error(501, '非法的url');
        }

        $wechat = new \Wechat(C("WX_CONF"));

        $js_sign = $wechat->getJsSign($url);
        
        if (C('DEV')) {
            $js_sign = [
                'appId'     => '11',
                'timestamp' => '11',
                'nonceStr'  => '11',
                'signature' => '11',
            ];
        }

        success($js_sign);
    }
}
